home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Oct 89 / Z0173-Re File Filter Meth-Oct89 < prev    next >
Encoding:
Text File  |  1989-10-25  |  1.2 KB  |  43 lines  |  [TEXT/GEOL]

  1. Item    6369948                         25-Oct-89        08:29
  2.  
  3. From:   CDA0004                         VAR Shana Enterprises, Don Murphy
  4.  
  5. To:     D2086                           Efficient Field Svc, C Faith,PRT
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    Re- File Filter Methods
  10.  
  11. Curtis,
  12.  
  13. A method can't be a fileFilter under normal circumstances.  You can't take the
  14. address of a method since you won't know which implementation to use until run
  15. time, when you can see what the class of the object is.
  16.  
  17. This goes back to the discussion some time ago about compile time vs. run time
  18. typing (is it a TObject, a TMammal, or a TDog?).
  19.  
  20. You can make up a "plain Pascal" procedure to be you file filter, and just pass
  21. the buck to a method of a global object:
  22.  
  23. VAR
  24.     gMyObject : TMyObject;
  25.  
  26.  
  27. FUNCTION FilterGlue (pb : ParamBlkPtr) : Boolean;
  28. BEGIN
  29.     FilterGlue := gMyObject.FileFilter (pb);
  30. END;
  31.  
  32.  
  33. Easy.  You can encapsulate the whole thing in a Unit, hiding both the global
  34. and the FilterGlue procedure, and preserve your OO pride.  And it keeps the
  35. method dispatcher involved, so no worries about possible future OVERRIDES and
  36. re-use of your code.
  37.  
  38. Regards,
  39.  
  40. Wayne Malkin
  41.  
  42.  
  43.